
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>django.template.engine &#8212; Django 2.2.12.dev20200304094918 documentation</title>
    <link rel="stylesheet" href="../../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../../_static/doctools.js"></script>
    <script type="text/javascript" src="../../../_static/language_data.js"></script>
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" />



 
<script type="text/javascript" src="../../../templatebuiltins.js"></script>
<script type="text/javascript">
(function($) {
    if (!django_template_builtins) {
       // templatebuiltins.js missing, do nothing.
       return;
    }
    $(document).ready(function() {
        // Hyperlink Django template tags and filters
        var base = "../../../ref/templates/builtins.html";
        if (base == "#") {
            // Special case for builtins.html itself
            base = "";
        }
        // Tags are keywords, class '.k'
        $("div.highlight\\-html\\+django span.k").each(function(i, elem) {
             var tagname = $(elem).text();
             if ($.inArray(tagname, django_template_builtins.ttags) != -1) {
                 var fragment = tagname.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>");
             }
        });
        // Filters are functions, class '.nf'
        $("div.highlight\\-html\\+django span.nf").each(function(i, elem) {
             var filtername = $(elem).text();
             if ($.inArray(filtername, django_template_builtins.tfilters) != -1) {
                 var fragment = filtername.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>");
             }
        });
    });
})(jQuery);</script>

  </head><body>

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../../../index.html">Django 2.2.12.dev20200304094918 documentation</a></h1>
      <div id="global-nav">
        <a title="Home page" href="../../../index.html">Home</a>  |
        <a title="Table of contents" href="../../../contents.html">Table of contents</a>  |
        <a title="Global index" href="../../../genindex.html">Index</a>  |
        <a title="Module index" href="../../../py-modindex.html">Modules</a>
      </div>
      <div class="nav">
    <a href="../../index.html" title="Module code" accesskey="U">up</a></div>
    </div>

    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="_modules-django-template-engine">
            
  <h1>Source code for django.template.engine</h1><div class="highlight"><pre>
<span></span><span class="kn">import</span> <span class="nn">functools</span>

<span class="kn">from</span> <span class="nn">django.core.exceptions</span> <span class="k">import</span> <span class="n">ImproperlyConfigured</span>
<span class="kn">from</span> <span class="nn">django.utils.functional</span> <span class="k">import</span> <span class="n">cached_property</span>
<span class="kn">from</span> <span class="nn">django.utils.module_loading</span> <span class="k">import</span> <span class="n">import_string</span>

<span class="kn">from</span> <span class="nn">.base</span> <span class="k">import</span> <span class="n">Context</span><span class="p">,</span> <span class="n">Template</span>
<span class="kn">from</span> <span class="nn">.context</span> <span class="k">import</span> <span class="n">_builtin_context_processors</span>
<span class="kn">from</span> <span class="nn">.exceptions</span> <span class="k">import</span> <span class="n">TemplateDoesNotExist</span>
<span class="kn">from</span> <span class="nn">.library</span> <span class="k">import</span> <span class="n">import_library</span>


<div class="viewcode-block" id="Engine"><a class="viewcode-back" href="../../../ref/templates/api.html#django.template.Engine">[docs]</a><span class="k">class</span> <span class="nc">Engine</span><span class="p">:</span>
    <span class="n">default_builtins</span> <span class="o">=</span> <span class="p">[</span>
        <span class="s1">&#39;django.template.defaulttags&#39;</span><span class="p">,</span>
        <span class="s1">&#39;django.template.defaultfilters&#39;</span><span class="p">,</span>
        <span class="s1">&#39;django.template.loader_tags&#39;</span><span class="p">,</span>
    <span class="p">]</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dirs</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">app_dirs</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">context_processors</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                 <span class="n">debug</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">loaders</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">string_if_invalid</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span>
                 <span class="n">file_charset</span><span class="o">=</span><span class="s1">&#39;utf-8&#39;</span><span class="p">,</span> <span class="n">libraries</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">builtins</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">autoescape</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">dirs</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">dirs</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">if</span> <span class="n">context_processors</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">context_processors</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">if</span> <span class="n">loaders</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">loaders</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;django.template.loaders.filesystem.Loader&#39;</span><span class="p">]</span>
            <span class="k">if</span> <span class="n">app_dirs</span><span class="p">:</span>
                <span class="n">loaders</span> <span class="o">+=</span> <span class="p">[</span><span class="s1">&#39;django.template.loaders.app_directories.Loader&#39;</span><span class="p">]</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">debug</span><span class="p">:</span>
                <span class="n">loaders</span> <span class="o">=</span> <span class="p">[(</span><span class="s1">&#39;django.template.loaders.cached.Loader&#39;</span><span class="p">,</span> <span class="n">loaders</span><span class="p">)]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">app_dirs</span><span class="p">:</span>
                <span class="k">raise</span> <span class="n">ImproperlyConfigured</span><span class="p">(</span>
                    <span class="s2">&quot;app_dirs must not be set when loaders is defined.&quot;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">libraries</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">libraries</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">if</span> <span class="n">builtins</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">builtins</span> <span class="o">=</span> <span class="p">[]</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">dirs</span> <span class="o">=</span> <span class="n">dirs</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">app_dirs</span> <span class="o">=</span> <span class="n">app_dirs</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">autoescape</span> <span class="o">=</span> <span class="n">autoescape</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">context_processors</span> <span class="o">=</span> <span class="n">context_processors</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">debug</span> <span class="o">=</span> <span class="n">debug</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">loaders</span> <span class="o">=</span> <span class="n">loaders</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">string_if_invalid</span> <span class="o">=</span> <span class="n">string_if_invalid</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">file_charset</span> <span class="o">=</span> <span class="n">file_charset</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">libraries</span> <span class="o">=</span> <span class="n">libraries</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">template_libraries</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_template_libraries</span><span class="p">(</span><span class="n">libraries</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">builtins</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">default_builtins</span> <span class="o">+</span> <span class="n">builtins</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">template_builtins</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_template_builtins</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">builtins</span><span class="p">)</span>

<div class="viewcode-block" id="Engine.get_default"><a class="viewcode-back" href="../../../ref/templates/api.html#django.template.Engine.get_default">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="nd">@functools</span><span class="o">.</span><span class="n">lru_cache</span><span class="p">()</span>
    <span class="k">def</span> <span class="nf">get_default</span><span class="p">():</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Return the first DjangoTemplates backend that&#39;s configured, or raise</span>
<span class="sd">        ImproperlyConfigured if none are configured.</span>

<span class="sd">        This is required for preserving historical APIs that rely on a</span>
<span class="sd">        globally available, implicitly configured engine such as:</span>

<span class="sd">        &gt;&gt;&gt; from django.template import Context, Template</span>
<span class="sd">        &gt;&gt;&gt; template = Template(&quot;Hello {{ name }}!&quot;)</span>
<span class="sd">        &gt;&gt;&gt; context = Context({&#39;name&#39;: &quot;world&quot;})</span>
<span class="sd">        &gt;&gt;&gt; template.render(context)</span>
<span class="sd">        &#39;Hello world!&#39;</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># Since Engine is imported in django.template and since</span>
        <span class="c1"># DjangoTemplates is a wrapper around this Engine class,</span>
        <span class="c1"># local imports are required to avoid import loops.</span>
        <span class="kn">from</span> <span class="nn">django.template</span> <span class="k">import</span> <span class="n">engines</span>
        <span class="kn">from</span> <span class="nn">django.template.backends.django</span> <span class="k">import</span> <span class="n">DjangoTemplates</span>
        <span class="k">for</span> <span class="n">engine</span> <span class="ow">in</span> <span class="n">engines</span><span class="o">.</span><span class="n">all</span><span class="p">():</span>
            <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">engine</span><span class="p">,</span> <span class="n">DjangoTemplates</span><span class="p">):</span>
                <span class="k">return</span> <span class="n">engine</span><span class="o">.</span><span class="n">engine</span>
        <span class="k">raise</span> <span class="n">ImproperlyConfigured</span><span class="p">(</span><span class="s1">&#39;No DjangoTemplates backend is configured.&#39;</span><span class="p">)</span></div>

    <span class="nd">@cached_property</span>
    <span class="k">def</span> <span class="nf">template_context_processors</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">context_processors</span> <span class="o">=</span> <span class="n">_builtin_context_processors</span>
        <span class="n">context_processors</span> <span class="o">+=</span> <span class="nb">tuple</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">context_processors</span><span class="p">)</span>
        <span class="k">return</span> <span class="nb">tuple</span><span class="p">(</span><span class="n">import_string</span><span class="p">(</span><span class="n">path</span><span class="p">)</span> <span class="k">for</span> <span class="n">path</span> <span class="ow">in</span> <span class="n">context_processors</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">get_template_builtins</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">builtins</span><span class="p">):</span>
        <span class="k">return</span> <span class="p">[</span><span class="n">import_library</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">builtins</span><span class="p">]</span>

    <span class="k">def</span> <span class="nf">get_template_libraries</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">libraries</span><span class="p">):</span>
        <span class="n">loaded</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">path</span> <span class="ow">in</span> <span class="n">libraries</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
            <span class="n">loaded</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">import_library</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">loaded</span>

    <span class="nd">@cached_property</span>
    <span class="k">def</span> <span class="nf">template_loaders</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_template_loaders</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">loaders</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">get_template_loaders</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">template_loaders</span><span class="p">):</span>
        <span class="n">loaders</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">template_loader</span> <span class="ow">in</span> <span class="n">template_loaders</span><span class="p">:</span>
            <span class="n">loader</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">find_template_loader</span><span class="p">(</span><span class="n">template_loader</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">loader</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                <span class="n">loaders</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">loader</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">loaders</span>

    <span class="k">def</span> <span class="nf">find_template_loader</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">loader</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">loader</span><span class="p">,</span> <span class="p">(</span><span class="nb">tuple</span><span class="p">,</span> <span class="nb">list</span><span class="p">)):</span>
            <span class="n">loader</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span> <span class="o">=</span> <span class="n">loader</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">args</span> <span class="o">=</span> <span class="p">[]</span>

        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">loader</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
            <span class="n">loader_class</span> <span class="o">=</span> <span class="n">import_string</span><span class="p">(</span><span class="n">loader</span><span class="p">)</span>
            <span class="k">return</span> <span class="n">loader_class</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">raise</span> <span class="n">ImproperlyConfigured</span><span class="p">(</span>
                <span class="s2">&quot;Invalid value in template loaders configuration: </span><span class="si">%r</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">loader</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">find_template</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">dirs</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">skip</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="n">tried</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">loader</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">template_loaders</span><span class="p">:</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="n">template</span> <span class="o">=</span> <span class="n">loader</span><span class="o">.</span><span class="n">get_template</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">skip</span><span class="o">=</span><span class="n">skip</span><span class="p">)</span>
                <span class="k">return</span> <span class="n">template</span><span class="p">,</span> <span class="n">template</span><span class="o">.</span><span class="n">origin</span>
            <span class="k">except</span> <span class="n">TemplateDoesNotExist</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
                <span class="n">tried</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">tried</span><span class="p">)</span>
        <span class="k">raise</span> <span class="n">TemplateDoesNotExist</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">tried</span><span class="o">=</span><span class="n">tried</span><span class="p">)</span>

<div class="viewcode-block" id="Engine.from_string"><a class="viewcode-back" href="../../../ref/templates/api.html#django.template.Engine.from_string">[docs]</a>    <span class="k">def</span> <span class="nf">from_string</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">template_code</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Return a compiled Template object for the given template code,</span>
<span class="sd">        handling template inheritance recursively.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">Template</span><span class="p">(</span><span class="n">template_code</span><span class="p">,</span> <span class="n">engine</span><span class="o">=</span><span class="bp">self</span><span class="p">)</span></div>

<div class="viewcode-block" id="Engine.get_template"><a class="viewcode-back" href="../../../ref/templates/api.html#django.template.Engine.get_template">[docs]</a>    <span class="k">def</span> <span class="nf">get_template</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">template_name</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Return a compiled Template object for the given template name,</span>
<span class="sd">        handling template inheritance recursively.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">template</span><span class="p">,</span> <span class="n">origin</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">find_template</span><span class="p">(</span><span class="n">template_name</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">template</span><span class="p">,</span> <span class="s1">&#39;render&#39;</span><span class="p">):</span>
            <span class="c1"># template needs to be compiled</span>
            <span class="n">template</span> <span class="o">=</span> <span class="n">Template</span><span class="p">(</span><span class="n">template</span><span class="p">,</span> <span class="n">origin</span><span class="p">,</span> <span class="n">template_name</span><span class="p">,</span> <span class="n">engine</span><span class="o">=</span><span class="bp">self</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">template</span></div>

    <span class="k">def</span> <span class="nf">render_to_string</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">template_name</span><span class="p">,</span> <span class="n">context</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Render the template specified by template_name with the given context.</span>
<span class="sd">        For use in Django&#39;s test suite.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">template_name</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">)):</span>
            <span class="n">t</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">select_template</span><span class="p">(</span><span class="n">template_name</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">t</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_template</span><span class="p">(</span><span class="n">template_name</span><span class="p">)</span>
        <span class="c1"># Django &lt; 1.8 accepted a Context in `context` even though that&#39;s</span>
        <span class="c1"># unintended. Preserve this ability but don&#39;t rewrap `context`.</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="n">Context</span><span class="p">):</span>
            <span class="k">return</span> <span class="n">t</span><span class="o">.</span><span class="n">render</span><span class="p">(</span><span class="n">context</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">t</span><span class="o">.</span><span class="n">render</span><span class="p">(</span><span class="n">Context</span><span class="p">(</span><span class="n">context</span><span class="p">))</span>

<div class="viewcode-block" id="Engine.select_template"><a class="viewcode-back" href="../../../ref/templates/api.html#django.template.Engine.select_template">[docs]</a>    <span class="k">def</span> <span class="nf">select_template</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">template_name_list</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Given a list of template names, return the first that can be loaded.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">template_name_list</span><span class="p">:</span>
            <span class="k">raise</span> <span class="n">TemplateDoesNotExist</span><span class="p">(</span><span class="s2">&quot;No template names provided&quot;</span><span class="p">)</span>
        <span class="n">not_found</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">template_name</span> <span class="ow">in</span> <span class="n">template_name_list</span><span class="p">:</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_template</span><span class="p">(</span><span class="n">template_name</span><span class="p">)</span>
            <span class="k">except</span> <span class="n">TemplateDoesNotExist</span> <span class="k">as</span> <span class="n">exc</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">exc</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">not_found</span><span class="p">:</span>
                    <span class="n">not_found</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exc</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                <span class="k">continue</span>
        <span class="c1"># If we get here, none of the templates could be loaded</span>
        <span class="k">raise</span> <span class="n">TemplateDoesNotExist</span><span class="p">(</span><span class="s1">&#39;, &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">not_found</span><span class="p">))</span></div></div>
</pre></div>

          </div>
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">Mar 04, 2020</p>
          </div>
        
      
    </div>

    <div id="ft">
      <div class="nav">
    <a href="../../index.html" title="Module code" accesskey="U">up</a></div>
    </div>
  </div>

      <div class="clearer"></div>
    </div>
  </body>
</html>